package cn.edu.buu.hospital.service.impl;
import cn.edu.buu.hospital.entity.User;
import cn.edu.buu.hospital.mapper.AdminMapper;
import cn.edu.buu.hospital.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
@Transactional
public class AdminServiceImpl implements AdminService {
    @Autowired
    private AdminMapper adminMapper;
    @Override
    public void add(User admin){
        adminMapper.insert(admin);
    }
    @Override
    @Transactional(readOnly = true)
    public List<User> findAllAdmins() {
        return adminMapper.selectAllAdmins();
    }
    @Override
    @Transactional(readOnly = true)
    public User findById(Integer userId) {
        return adminMapper.selectById(userId);
    }
    @Override
    public void update(User admin) {
        adminMapper.update(admin);
    }
    @Override
    public void deleteById(Integer userId) {
        adminMapper.deleteById(userId);
    }
}
